// const studentsData = {
//     "name": "Alice",
//     "name": "Bob"
// };
// console.log(studentsData); 
// // 输出结果为: {"name": "Bob"}



// const studentsData2 = {
//     "name": "Alice",
//     [Symbol('name')]: "Bob"
// };
// console.log(studentsData);
// // 输出结果为: {"name": "Alice", Symbol(name): "Bob"}

const classmates = {
    // 字符串同名覆盖
    "cy": 1,
    "cy": 2
};
console.log(classmates); 
// 输出结果为: {cy: 2}

// console.log("------------");

const classmates2 = {
    "cy": 1,
    "cy": 2,
    [Symbol('olivia')]: {grade: 60, age: 18},
    [Symbol('olivia')]: {grade: 60, age: 19}
};
console.log(classmates2);
// 输出结果为: {
//     cy: 2,
//     [Symbol(olivia)]: {grade: 60, age: 18},
//     [Symbol(olivia)]: {grade: 60, age: 19}
// }


console.log("------------");




const name = "xbk";
const classmates3 = {
    [name]: "猛男"
};
console.log(classmates3); 
// 输出结果为: {xbk: '猛男'}


console.log("------------");


const anotherObj = {
    key1: 'value1',
    key2: 'value2'
};
for (let key in anotherObj) {
    console.log(key, anotherObj[key]);
}
// 输出: 
// key1 value1
// key2 value2


console.log("------------");

const myObj = {
    cy: 1,
    [Symbol('sym1')]: 'value1',
    [Symbol('sym2')]: 'value2'
};
const symbolArray = Object.getOwnPropertySymbols(myObj);
console.log(symbolArray); 
// 输出: [Symbol(sym1), Symbol(sym2)]



console.log("------------");


for (let key of symbolArray) {
    console.log(key, myObj[key]);
}
// 输出: 
// Symbol(sym1) value1
// Symbol(sym2) value2

console.log("------------");

console.log("------------");
const descriptorObj = {
    stringProp: 'value',
    [Symbol('symProp')]: 'symbolValue'
};
const descriptors = Object.getOwnPropertyDescriptors(descriptorObj);
for (let key in descriptors) {
    if (typeof key === 'symbol') {
        console.log(key, descriptorObj[key]);
    }
}
console.log("------------");

